package vuelos;

import java.util.Date;
import java.util.List;

import com.minube.flights.client.FlightReader;
import com.minube.flights.data.FlightBoard;
import com.minube.flights.data.FlightEntry;
import com.minube.flights.util.FlightException;

/**
 * Controlador del servicio de informacion meteorologica.
 * 
 * @author Jaime A. Corrales Gonzalez
 * 
 * @version 0.001a
 */
public class ControladorVuelos {

	public ControladorVuelos () {
		
	}
	
	public List<FlightEntry> getFlights (String source, String destination, Date departureDate, Date returnDate) {
		try {
			FlightReader fr = new FlightReader(source, destination, departureDate, returnDate);
			
			fr.launchQuery();
			
			try {
				Thread.sleep(1000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			
			fr.process();
			
			FlightBoard board = fr.getFlightBoard();
			
			return board.getBoard();
		} catch (FlightException e) {
			return null;
		}
	}
}
